package wangwenjun.phase3.executor.completablefuture.demo01;

import lombok.extern.slf4j.Slf4j;
import util.ThreadUtil;

import java.util.concurrent.ThreadLocalRandom;

/**
 * @author ChangLiang
 * @date 2020/6/23
 */
@Slf4j
public class DbQueryHandler {

    public static String handleUserDbQuery(UserObject user) {
        int value = ThreadLocalRandom.current().nextInt(10);
        ThreadUtil.sleepForSeconds(value);
        log.info("handle db query, mobile:{}, time consumption:{} seconds", user.getMobile(), value);
        StringBuilder builder = new StringBuilder();
        return builder.append("name:").append(user.getName()).append("&mobile:").append(user.getMobile()).toString();
    }
}
